package com.hermeneute.fsa;
import java.util.HashSet;
import java.util.Stack;


class FSTPivotStack
{
    FSTAutomaton ia;
    Stack stack;
    HashSet mark;
    
    FSTPivotStack (FSTAutomaton a) {
	ia = a;
	stack = new Stack();
	mark = new HashSet();
    }
    
    int size() {
      return stack.size(); 
    }
    
    void print() {
	System.out.println(stack);
    }
    
    void push(FSTPivot v) {
	if(!mark.contains(v)) {
	    mark.add(v);
	    stack.push(v);
	}
    }

  FSTPivot pop() {
      FSTPivot p = (FSTPivot)stack.pop();
      mark.remove(p);
      return p;
  }

  boolean exists (FSTPivot p) {
    return mark.contains(p);
  }

  boolean exists (int i, FSTEvent e)
  {
    return mark.contains(new FSTPivot (i,e));
  }

  boolean isEmpty() {
    return stack.empty();
  }

}
